<!DOCTYPE html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
  <head>
    <title>property to attribute reflection with bind</title>
    <script src="../../../webcomponentsjs/webcomponents.js"></script>
    <link rel="import" href="../../polymer.html">
    <script src="../../../tools/test/htmltest.js"></script>
    <script src="../../../tools/test/chai/chai.js"></script>
  </head>

  <body>
    <polymer-element name="my-child-element">
      <template>
        <h1>Hello from the child</h1>
        <p>The camelCase is {{camelCase}}, attr is {{attributes.camelCase.value}}</p>
        <p>The lowercase is {{lowercase}}, attr is {{attributes.lowercase.value}}</p>
      </template>
      <script>
        Polymer('my-child-element', {
          publish: { 
            camelCase: {value: 0, reflect: true},
            lowercase: {value: 0, reflect: true}
          },
          // Make this a no-op, so we can verify the initial
          // reflectPropertyToAttribute works.
          observeAttributeProperty: function(name) { }
        });
      </script>
    </polymer-element>

    <polymer-element name="my-element">
      <template>
        <h1>Hello from the custom element. The volume is {{volume}}</h1>
        <p>
          <my-child-element id="child"
              camelCase="{{volume}}" lowercase="{{volume}}"></my-child-element>
        </p>
      </template>
      <script>
        Polymer('my-element', {
          publish: { volume: 11 },
          ready: function() {
            var child = this.$.child;
            chai.assert.equal(child.lowercase, 11);
            chai.assert.equal(child.camelCase, 11);

            chai.assert.equal('' + child.lowercase, child.getAttribute('lowercase'));
            chai.assert.equal('' + child.camelCase, child.getAttribute('camelcase'));

            done();
          }
        });
      </script>
    </polymer-element>

    <my-element></my-element>
  </body>
</html>
